package com.z.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.z.dao.ZpInfoDao;
import com.z.dto.ZpInfoDto;

public class ZpInfoDaoImpl extends BaseDaoImpl implements ZpInfoDao {

	public void insert(List<ZpInfoDto> list) {
		String sql = "insert zp_info ( zwmc, childPath, gsmc, zwyx, fk_lv, gzdd, xxms) values (?,?,?,?,?,?,?)";
		conn = this.getConnection();
		try {
			ps = conn.prepareStatement(sql);
			for (int i = 0; i < list.size(); i++) {
				ps.setString(1, list.get(i).getZwmc());
				ps.setString(2, list.get(i).getChildPath());
				ps.setString(3, list.get(i).getGsmc());
				ps.setString(4, list.get(i).getZwyx());
				ps.setString(5, list.get(i).getFk_lv());
				ps.setString(6, list.get(i).getGzdd());
				ps.setString(7, list.get(i).getXxms());
				ps.addBatch();
			}
			ps.executeBatch();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			try {
				this.closeConnection(conn, resultSet, ps);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}

	public ResultSet selectList(int begin,int end) {
		String sql=" select id, zwmc, childPath, gsmc, zwyx, fk_lv, gzdd, xxms from zp_info where 1=1 and id between ? and ?";
		conn = this.getConnection();
		try {
			ps = conn.prepareStatement(sql);
			ps.setInt(1,begin);
			ps.setInt(2, end);
			resultSet=ps.executeQuery();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return resultSet;
	}
}
